﻿@using Webdiyer.WebControls.Mvc
@model PagedList<NationalIT.Maintenance>
           <h3>Maintenance</h3>
<div class="row-fluid">
    <div class="span12">
        <div class="row-fluid">
            @Html.Partial("_MenuButtonNewEditOrDelete")
        </div>
        <table class="table">
            <tr>
                <th>
                    <input type="checkbox" name="" value="" class="checkAll" />
                </th>
                <th>
                    ID
                </th>
                <th>
                    Equipment_Number
                </th>
                <th>
                    Maintenance_performed
                </th>
                <th>
                    Performed_date
                </th>
                <th>
                    Location
                </th>
                <th>
                    PO_
                </th>
                <th>
                    ApprovedAmount
                </th>
                <th>
                    SpentAmount
                </th>
                <th>
                    ApprovedBy
                </th>
            </tr>
            @foreach (var item in Model)
            {
                <tr>
                    <td>
                        <input type="checkbox" name="checkOwner" value="@item.Id" class="checkitem"/>
                    </td>
                    <td>
                        @Html.ActionLink(item.Id.ToString(), "NewOrEdit", new { id = item.Id })
                    </td>
                    <td>
                        @(item.Equipment != null ? item.Equipment.Equipment_number : null)
                    </td>
                    <td>
                        @item.Maintenance_performed
                    </td>
                    <td>
                        @(item.Performed_date.HasValue?item.Performed_date.Value.ToString("MM/dd/yyyy"):"")
                    </td>
                    <td>
                        @item.Location
                    </td>
                    <td>
                        @item.PO_
                    </td>
                    <td>
                        @String.Format("{0:C}", item.ApprovedAmount)
                    </td>
                    <td>
                        @String.Format("{0:C}", item.SpentAmount)
                    </td>
                    <td>
                        @item.ApprovedBy
                    </td>
                </tr>
            }
        </table>
        <div class="row-fluid">
            <div class="span4">
                <div class="dataTables_info">
                    @if (Model.TotalItemCount > 0)
                    {
                        if (Model.TotalItemCount < Model.PageSize)
                        {
                        <span>1 </span>
                        <span>- </span>@Model.TotalItemCount
                        }
                        else
                        {
                        <span></span>@((Model.CurrentPageIndex - 1) * Model.PageSize + 1)
                        <span>- </span>@((Model.CurrentPageIndex != Model.TotalPageCount) ? (Model.CurrentPageIndex * Model.PageSize) : Math.Abs((Model.CurrentPageIndex) * Model.PageSize - (Model.PageSize * Model.TotalPageCount) - Model.TotalItemCount))
                        }
                        <span>of </span>@(Model.TotalItemCount)
                            
                    }
                </div>
            </div>
            <div class="span8">
                <div class="dataTables_paginate paging_bootstrap pagination phantrangmvcpager">
                    @* <ul>
                        <li class="prev disabled"><a href="#">← Prev</a></li><li class="active"><a href="#">
                            1</a></li><li><a href="#">2</a></li><li class="next"><a href="#">Next → </a>
                        </li>
                    </ul>*@
                    @Html.Pager(Model, new PagerOptions { ContainerTagName = "ul", PageIndexParameterName = "page", CurrentPagerItemWrapperFormatString = "<li class='active'>{0}</li>", CurrentPageNumberFormatString = "{0}", FirstPageText = "&laquo; ", LastPageText = " &raquo;", NextPageText = "Next →", PrevPageText = "← Prev", SeparatorHtml = "" })
                </div>
            </div>
        </div>
    </div>
</div>
